package day_6_28;

public class Main3 {
    /**
     * 73. 矩阵置零
     * https://leetcode.cn/problems/set-matrix-zeroes/description/
     */
    public void setZeroes(int[][] matrix) {
        int m = matrix.length;
        int n = matrix[0].length;
        boolean[] row = new boolean[m];
        boolean[] col = new boolean[n];
        for(int i = 0;i < m;i++) {
            for(int j = 0;j < n;j++) {
                if(matrix[i][j] == 0) {
                    row[i] = col[j] = true;
                }
            }
        }

        for(int i = 0;i < m;i++) {
            for(int j = 0;j < n;j++) {
                if(row[i] == true || col[j] == true) {
                    matrix[i][j] = 0;
                }
            }
        }
    }
}
